package com.fz.controller;

import com.fz.service.StudentService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * Created by Z-C-Y on 2018-02-01.
 */
@Controller
public class StudentController {
    /*从数据库中把数据拿出来*/
    @RequestMapping("")
    public ModelAndView show(){
        ModelAndView mv = new ModelAndView("index");
        mv.addObject("st",new StudentService().queryAll());
        return mv;
    }

    /*根据id进行删除数据*/
    @RequestMapping("/del")
    public String del(int id){
      new StudentService().deleteById(id);
      return "redirect:/";
    }

    /*向数据库中添加数据*/
    @RequestMapping("/add") @ResponseBody
    public void  add(String name){
    }





}
